<template>
	<view class="container">
		<u--form ref="queryForm" :model="query" label-width="120rpx">
			<u-form-item label="料架码" prop="rackCode">
			  <u--input 
			  	placeholder="请输入/扫描" 
			  	v-model.trim="query.rackCode" 
			  	suffixIcon="scan" 
			  	suffixIconStyle="font-size: 68rpx"
			  	style="flex: 1;"	
					@confirm="checkIsLightUp"
			  >
			  </u--input>
			</u-form-item>
		</u--form>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	import { checkIsLightAPI } from '@/api/work/outbound.js'
	export default {
		data() {
			return {
				query: {
					rackCode: ''
				}
			};
		},
		computed: {
			...mapState(['macAddress'])
		},
		methods: {
			async checkIsLightUp() {
				const submitForm = {
					rackCode: this.query.rackCode,
					url: this.macAddress
				}
				const res = await checkIsLightAPI(submitForm)
				if (res.code === 200) {
					console.log(res)
					if (res.data === true) {
						uni.navigateTo({
							url: `/pages/work/outbound/shelfPage/lightShelfUp?rackCode=${this.query.rackCode}`
						})
					} else {
						uni.navigateTo({
							url: `/pages/work/outbound/shelfPage/commonShelfUp?rackCode=${this.query.rackCode}`
						})
					}
				} else {
					return this.$refs.uToast.show({
						type: 'warning',
						message: res.message
					})
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
